home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Library / Manuels & Misc / Assembly / AOA.ZIP / CH06 / PGM6_8.ASM < prev    next >
Encoding:
Assembly Source File  |  1994-10-10  |  1.7 KB  |  98 lines

  1. ; CALL and INT Instructions
  2.  
  3.         .386
  4.         option    segment:use16
  5.  
  6. dseg        segment    para public 'data'
  7.  
  8. ; Some pointers to our subroutines:
  9.  
  10. SPtr1        word    Subroutine1
  11. SPtr2        dword    Subroutine2
  12.  
  13. dseg        ends
  14.  
  15.  
  16. cseg        segment    para public 'code'
  17.         assume    cs:cseg, ds:dseg
  18.  
  19. Subroutine1    proc    near
  20.         ret
  21. Subroutine1    endp
  22.  
  23. Subroutine2    proc    far
  24.         ret
  25. Subroutine2    endp
  26.  
  27.  
  28. Main        proc
  29.         mov    ax, dseg
  30.         mov    ds, ax
  31.         mov    es, ax
  32.  
  33. ; Near call:
  34.  
  35.         call    Subroutine1
  36.  
  37. ; Far call:
  38.  
  39.         call    Subroutine2
  40.  
  41. ; Near register-indirect call:
  42.  
  43.         lea    cx, Subroutine1
  44.         call    cx
  45.  
  46. ; Near memory-indirect call:
  47.  
  48.         call    SPtr1
  49.  
  50. ; Far memory-indirect call:
  51.  
  52.         call    SPtr2
  53.  
  54.  
  55. ; INT transfers control to a routine whose
  56. ; address appears in the interrupt vector
  57. ; table (see Chapter 15 for details on
  58. ; the interrupt vector table). The following
  59. ; call tells the PC's BIOS to print the
  60. ; ASCII character in AL to the display.
  61.  
  62.         mov    ah, 0eh
  63.         mov    al, 'A'
  64.         int    10h
  65.  
  66. ; INTO generates an INT 4 if the 80x86
  67. ; overflow flag is set.  It becomes a
  68. ; NOP if the overflow flag is clear.
  69. ; You can use this instruction after
  70. ; an arithmetic operation to quickly
  71. ; test for a fatal overflow.  Note:
  72. ; the following sequence does *not*
  73. ; generate an overflow.  Do not modify
  74. ; it so that it does unless you add an
  75. ; INT 4 interrupt service routine to
  76. ; the interrupt vector table (see Chapter
  77. ; 15 for details)
  78.  
  79.         mov    ax, 2
  80.         add    ax, 4
  81.         into
  82.  
  83.  
  84. Quit:        mov    ah, 4ch
  85.         int    21h
  86. Main        endp
  87.  
  88. cseg        ends
  89.  
  90. sseg        segment    para stack 'stack'
  91. stk        byte    1024 dup ("stack   ")
  92. sseg        ends
  93.  
  94. zzzzzzseg    segment    para public 'zzzzzz'
  95. LastBytes    byte    16 dup (?)
  96. zzzzzzseg    ends
  97.         end    Main
  98.